<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>SpaceLab</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="_token" content="{{ csrf_token() }}"/>
    <!-- Favicon -->
    <link rel="shortcut icon" href="{{asset('admin/img/favicon.ico')}}" type="image/x-icon">
    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="{{asset('admin/plugins/bootstrap/css/bootstrap.min.css')}}">
    <!-- Fonts from Font Awsome -->
    <link rel="stylesheet" href="{{asset('admin/css/font-awesome.min.css')}}">
    <!-- CSS Animate -->
    <link rel="stylesheet" href="{{asset('admin/css/animate.css')}}">
    <!-- Custom styles for this theme -->
    <link rel="stylesheet" href="{{asset('admin/css/main.css')}}">
    <!-- iCheck-->
    <link rel="stylesheet" href="{{asset('admin/plugins/icheck/css/_all.css')}}">
    <!-- Fonts -->
    <!-- <link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,900,300italic,400italic,600italic,700italic,900italic' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'> -->
    <!-- Feature detection -->
    <script src="{{asset('admin/js/modernizr-2.6.2.min.js')}}"></script>
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="assets/js/html5shiv.js"></script>
    <script src="assets/js/respond.min.js"></script>
    <![endif]-->
    <style>
        .pagination{
            float: right;
            margin: 0px ;
        }
        .mail-option{
            margin: 0 0 15px;
        }
        body{
        	background:transparent;
        	margin: 0px;
        }
    </style>
</head>
<body>
    <section class="panel" style="margin:0px;">
        <header class="panel-heading wht-bg">
            <h4 class="gen-case">留言列表(83)
                <form action="#" class="pull-right mail-src-position">
                    <div class="input-append">
                        <input type="text" class="form-control " placeholder="搜索留言...">
                    </div>
                </form>
            </h4>
        </header>
        <div class="panel-body minimal">
            <div class="mail-option">
                <div class="pull-left mail-checkbox ">
                    <input type="checkbox" id="full">
                </div>
                <div class="btn-group">
                    <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
                        全部留言
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu" role="menu">
                        <li><a href="{{ url('centre')}}">全部留言</a>
                        </li>
                        <li><a href="{{ url('centre','xing')}}">热门留言</a>
                        </li>
                        <li><a href="{{ url('centre','normal')}}">普通留言</a>
                        </li>
                        <li><a href="{{ url('centre','lose')}}">垃圾留言</a>
                        </li>
                    </ul>
                </div>
                <div class="btn-group">
                    <a data-original-title="Refresh" data-placement="top" data-toggle="tooltip" href="#" class="btn btn-default btn-sm tooltips">
                        <i class=" fa fa-refresh"></i>
                    </a>
                </div>

                <div class="btn-group">
                    <button type="button" class="btn btn-default dropdown-toggle btn-sm" data-toggle="dropdown">
                        更多
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu" role="menu">
                        <li id="lose"><a href="#"><i class="fa fa-ban"></i> 垃圾留言</a>
                        </li>
                        <li id="delete"><a href="#"><i class="fa fa-trash-o" ></i>删除留言</a>
                        </li>
                    </ul>
                </div>
               
            </div>
            <!-- 题目开始 -->
            <div class="table-responsive">
                <table class="table table-inbox table-hover" border="0" scrolling="no">
                    <tbody scrolling="no">
                        @foreach($res as $v)
                        <tr class="unread">
                            <td>
                                <input type="checkbox" class="mail-checkbox" id="{{$v->commentid}}">
                            </td>
                            <!-- 是否是星 -->
                            <td>
                                @if($v->status === 1 )
                                <i class="fa fa-star"></i>
                                @else
                                <i class="fa fa-star-o"></i>
                                @endif
                            </td>
                            <td class="message">
                                <a href="{{ url('you' , [$v->commentid]) }}" name="hahaha" target="you">
                                    <span class="title">{{$v->title}}</span>
                                    {{$v->main_content}}
                                </a>
                            </td>
                            <td class="text-right">{{date('m-d H:i',strtotime($v->creat_at))}}<i class="fa fa-paperclip"></i>
                            </td>
                        </tr>
                        @endforeach
                    </tbody>
                </table>

            </div>
                <!-- 分页开始 -->
                        {!! $res->render() !!}
                <!-- 分页结束 -->
        </div>
    </section>
    <script src="{{asset('admin/js/jquery-1.10.2.min.js')}}"></script>
    <script src="{{asset('admin/plugins/bootstrap/js/bootstrap.min.js')}}"></script>
    <script src="{{asset('admin/plugins/waypoints/waypoints.min.js')}}"></script>
    <script src="{{asset('admin/js/application.js')}}"></script>
    <!--Page Level JS-->
    <script src="{{asset('admin/plugins/icheck/js/icheck.min.js')}}"></script>
    <script>
    var shu =[];
    $(document).ready(function() {
        $('input').iCheck({
            checkboxClass: 'icheckbox_flat-green'
        });
        $('.tooltips').tooltip();
        $("#full").on('ifChecked', function(event){
            
             $('div[class="icheckbox_flat-green"]').attr("class","icheckbox_flat-green checked");
             $("input[type='checkbox']").prop("checked",true);
             // $("input[type='checkbox']").prop("class",'icheckbox_flat-green checked');
             //window.location.reload();
        });
        $("#full").on('ifUnchecked', function(event){
            $('div[class="icheckbox_flat-green checked"]').attr("class","icheckbox_flat-green");
            $("input[type='checkbox']").prop("checked",false);
            //window.location.reload();
        });
        $('input').on('ifChecked', function(event){
        	shu[event.target.id-1] = event.target.id;
		});
        $('input').on('ifUnchecked', function(event){
        	
        	shu.splice(event.target.id-1,1);
  			// unset (shu[event.target.id]);
  			
		});
    }); 
    var del = document.getElementById('delete');
    del.onclick = function (){
        var xhr = new XMLHttpRequest();
    	var token = "{{ csrf_token() }}";
        xhr.onreadystatechange = function (){
	        if(this.readyState == 4){
        	    var j = this.responseText;
                if (j == '删除成功') {
                    window.location.reload();
                }else{
                    alert(j);
                } 
	        }
	    } 
        var aa = 'cal=del&shu='+shu;
	    xhr.open('POST','',true);
        xhr.setRequestHeader('X-CSRF-TOKEN',token);
        xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded');
        xhr.send(aa);
	}
    var lose = document.getElementById('lose');
    lose.onclick = function (){
        var xhr = new XMLHttpRequest();
        var token = "{{ csrf_token() }}";
        xhr.onreadystatechange = function (){
            if(this.readyState == 4){
                var j = this.responseText;
                if (j == '设置成功') {
                    window.location.reload();
                }
            }
        } 
        var aa = 'cal=lose&shu='+shu;
        xhr.open('POST','',true);
        xhr.setRequestHeader('X-CSRF-TOKEN',token);
        xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded');
        xhr.send(aa);
    }
    </script>
</body>
</html>